<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>
        <script>
             new Promise((resolve, reject) => {
                setTimeout(()=>{
                    reject('失败的数据')
                },1000)
            }).then(
                value=>{
                    console.log('onresovled()1',value)
                }
            ).catch(
                reason=>{
                    console.log('onrejected()1',reason)
                }
            )
            
            //产生一个成功值为1的promise的对象
            const p1= new Promise((resolve, reject) => {
                resolve(1)
            })
            //产生一个成功值为2的promise的对象
            const p2 = Promise.resolve(2) //语法糖
            //产生一个失败值为3的promise的对象
            const p3 = Promise.reject(3) //语法糖
            
            p1.then(value=>{console.log(value)})
            p2.then(value=>{console.log(value)})
            p3.catch(reason=>{console.log(reason)})
            
           const pall = Promise.all([p1,p2,p3])
           pall.then(
                    value=>{
                         console.log('all onrejected()',value)
                    },
                    reason=>{
                        console.log('all onrejected()',reason)
                        }
           )
          const prace = Promise.race([p1,p2,p3])
          prace.then(
                    value=>{
                         console.log('race onrejected()',value)
                    },
                    reason=>{
                        console.log('race onrejected()',reason)
                        }
           )
        </script> 
    </body>
</html>